package com.rongke.web;

import com.rongke.commons.JsonResp;
import com.rongke.model.AdminUserRole;
import com.rongke.service.AdminUserRoleService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @AdminUserRoleController
 * @Controller
 * @version : Ver 1.0
 */
@RestController
@RequestMapping(value="/api/adminUserRole")
@Transactional
@CrossOrigin
public class AdminUserRoleController {
    private Logger log = Logger.getLogger(this.getClass());
    @Autowired
    private AdminUserRoleService adminUserRoleService;



    /**
     * @修改
     * @param adminUserRole
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/update", method = RequestMethod.POST)
    public JsonResp updateAdminUserRole(@RequestBody AdminUserRole adminUserRole){
        log.debug("修改");
        adminUserRoleService.updateById(adminUserRole);
        return JsonResp.ok(adminUserRole);
    }
    /**
     * @根据id查找
     * @param id
     * @return 返回值JsonResp
     */
    @RequestMapping(value="/selectOne", method = RequestMethod.GET)
    public JsonResp selectAdminUserRole(Long id){
        log.debug("查找");
        AdminUserRole adminUserRole = adminUserRoleService.selectById(id);
        return JsonResp.ok(adminUserRole);
    }

    /**
     * @根据条件查找
     * @param adminUserRole
     * @return 返回值JsonResp
     */
    @RequestMapping(value = "/selectByCondition", method = RequestMethod.POST)
    public JsonResp selectAdminUserRoleByCondition(@RequestBody AdminUserRole adminUserRole){
        log.debug("根据条件查找");
        if(adminUserRole==null)
            return JsonResp.toFail("参数不能为空");
        List<AdminUserRole> adminUserRoleList=adminUserRoleService.selectByCondition(adminUserRole);
        return JsonResp.ok(adminUserRoleList);
    }

}
